<template>
    <!-- 历史变更页面 -->
    <div class="e-table">
        <el-table
            :data="alterationTable"
            border
            style="width: 100%"
            ref="table"
            class="table"
            v-sortTable="{
                tableData: alterationTable,
                _this: this,
                ref: 'table'
            }"
        >
            <el-table-column label="序号" type="index" width="60">
            </el-table-column>
            <el-table-column
                prop="subcontractorName"
                label="工程分包商名称"
                min-width="200"
                show-overflow-tooltip
            >
                <template slot-scope="scope">
                    <span
                        @click="Examine(scope.row)"
                        style="color: blue; cursor: pointer"
                    >
                        {{ scope.row.subcontractorName }}
                    </span>
                </template>
            </el-table-column>
            <el-table-column
                prop="registerCapital"
                label="注册资本（万元）"
                width="200"
            >
            </el-table-column>
            <el-table-column
                prop="creditCode"
                label="统一社会信用代码"
                width="190"
            >
            </el-table-column>
            <el-table-column prop="manageOrgName" label="管理单位" width="200">
            </el-table-column>
            <el-table-column
                prop="businessScopeName"
                label="主营范围"
                width="200"
            >
            </el-table-column>
            <el-table-column
                prop="qualificationLevelName"
                label="资质等级"
                width="150"
            >
            </el-table-column>
            <el-table-column prop="gmtCreate" label="变更时间" width="150">
            </el-table-column>
            <el-table-column prop="founderName" label="变更人" width="120">
            </el-table-column>
            <el-table-column prop="state" label="变更状态" width="80">
                <template slot-scope="scope">
                    {{
                        scope.row.state == 0
                            ? '草稿'
                            : scope.row.state == 1
                            ? '审核中'
                            : scope.row.state == 2
                            ? '已审核'
                            : ''
                    }}
                </template>
            </el-table-column>
        </el-table>
    </div>
</template>
<script>
import examine from '@/api/OutsourcingartyAdmin/subcontractorAdmin/examine.js'
export default {
    props: {
        billId: {
            type: String,
            default: '',
            require: true
        },
        alterationTable: {
            type: Array,
            default: () => {
                return []
            }
        }
    },
    data () {
        return {}
    },
    methods: {
        //点击分包商名字查看详情数据

        //点击表格查看
        Examine (row) {
            //点击进入查看页面
            const billid = row.id
            if (row.state === -1 || row.state === 2 || row.state === 5) {
                this.$router.push({
                    path: '/subcontractorChangeShow',
                    query: { billid }
                })
            } else {
                // 根据按钮状态来判断点击编辑进什么页面
                examine
                    .getCurrentUnitInfo({
                        billId: billid,
                        billType: 60401,
                        freeNextUnitIndex: 0,
                        freeNextUser: '',
                        isPass: true,
                        isShareInAudit: true,
                        opinion: ''
                    })
                    .then(res => {
                        this.auditState = res
                        if (this.auditState.canModify) {
                            this.$router.push({
                                path: '/subcontractorChangeEdit',
                                query: { billid }
                            })
                        } else {
                            this.$router.push({
                                path: '/subcontractorChangeShow',
                                query: { billid }
                            })
                        }
                    })
            }
        }
    }
}
</script>

<style lang="sass" scoped></style>
